home *** CD-ROM | disk | FTP | other *** search
- /**************************************************************************
- * *
- * Copyright (c) 1991 Silicon Graphics, Inc. *
- * All Rights Reserved *
- * *
- * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGI *
- * *
- * The copyright notice above does not evidence any actual of intended *
- * publication of such source code, and is an unpublished work by Silicon *
- * Graphics, Inc. This material contains CONFIDENTIAL INFORMATION that is *
- * the property of Silicon Graphics, Inc. Any use, duplication or *
- * disclosure not specifically authorized by Silicon Graphics is strictly *
- * prohibited. *
- * *
- * RESTRICTED RIGHTS LEGEND: *
- * *
- * Use, duplication or disclosure by the Government is subject to *
- * restrictions as set forth in subdivision (c)(1)(ii) of the Rights in *
- * Technical Data and Computer Software clause at DFARS 52.227-7013, *
- * and/or in similar or successor clauses in the FAR, DOD or NASA FAR *
- * Supplement. Unpublished - rights reserved under the Copyright Laws of *
- * the United States. Contractor is SILICON GRAPHICS, INC., 2011 N. *
- * Shoreline Blvd., Mountain View, CA 94039-7311 *
- **************************************************************************
- *
- * File: pinfo.c
- *
- * Description: Prints detailed information about the specified printer.
- *
- **************************************************************************/
-
-
- #ident "$Revision: 1.2 $"
-
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #ifdef sgi
- #include <getopt.h>
- #endif
- #include "spool.h"
-
-
- char *pname;
- int spooler = SL_SPOOLER_NONE;
-
-
- extern char *optarg;
- extern int optind;
-
-
- void usage(char*);
- void print_info(SLPrinterStruct*);
-
-
- main(int argc, char *argv[])
- {
- int ch;
- int errflag = 0;
- SLPrinterStruct *pinfo;
-
- /*
- * Process command line args
- */
- while ((ch = getopt(argc, argv, "s:")) != -1) {
- switch (ch) {
- case 's': /* Spooler to use */
- if (!strcmp(optarg, "bsd"))
- spooler = SL_SPOOLER_BSD;
- else if (!strcmp(optarg, "sysv"))
- spooler = SL_SPOOLER_SYSV;
- else
- errflag++;
- break;
- case '?':
- default:
- errflag++;
- break;
- }
- }
-
- /*
- * If error, print usage and exit
- */
- if (errflag) {
- usage(argv[0]);
- exit(1);
- }
-
- /*
- * If a spooling system has been specified set it
- */
- if (spooler != SL_SPOOLER_NONE) {
- if (SLSetSpooler(spooler) < 0) {
- SLPerror(argv[0]);
- exit(1);
- }
- }
-
- /*
- * Get the printer name
- */
- if (argc == optind) {
- if (SLGetDefPrinterName(&pname) < 0) {
- SLPerror(argv[0]);
- exit(1);
- }
- } else
- pname = argv[optind];
-
- /*
- * Get the printer information
- */
- if (SLGetPrinterInfo(pname, &pinfo) < 0) {
- SLPerror(argv[0]);
- exit(1);
- }
-
- /*
- * Print the information
- */
- print_info(pinfo);
-
- return 0;
- }
-
-
- void usage(char *progname)
- {
- (void)fprintf(stderr, "%s [-s bsd | sysv] [printer_name]\n", progname);
- }
-
-
- void print_info(SLPrinterStruct *ptr)
- {
- (void)printf("\n");
- (void)printf("\tName:\t\t%s\n", ptr->local_name);
- (void)printf("\tFormal Name:\t%s\n", ptr->formal_name);
- (void)printf("\tType:\t\t%s\n", ptr->type);
- (void)printf("\tDefault:\t%s\n", (ptr->is_def) ? "Yes": "No");
- (void)printf("\tClass:\t\t%s\n", (ptr->is_class) ? "Yes": "No");
- if (ptr->is_networked) {
- (void)printf("\tRemote host:\t%s\n", ptr->remote_host);
- (void)printf("\tRemote name:\t%s\n", ptr->remote_name);
- (void)printf("\tNetwork type:\t%s\n",
- ptr->network_type ? ptr->network_type : "Unknown");
- } else {
- (void)printf("\tDevice:\t\t%s\n", ptr->dev);
- }
- }
-
-